package com.medusa.aps.business.modules.security.mp.entity;


import cn.hutool.core.annotation.Alias;
import com.baomidou.mybatisplus.annotation.*;
import com.medusa.aps.business.model.BaseEntity;
import com.medusa.aps.business.model.enums.SourceEnum;
import com.medusa.aps.business.modules.security.model.output.RoleMenuVO;
import com.medusa.aps.business.modules.security.model.output.RoleUserVO;
import com.medusa.aps.business.common.security.model.enums.Roles;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;


/**
 * @author: xianhui.yu
 **/
@Data
@TableName("sys_role")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@Schema(name = "role", description = "角色信息定义")
public class Role extends BaseEntity<Role> {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "主键ID")
    private Integer id;
    /**
     * 角色名称
     */
    @TableField("name")
    @NotBlank(message = "角色名称不能为空")
    @Alias("角色名称")
    @Schema(description = "角色名称")
    private String name;

    /**
     * 角色值
     */
    @Schema(description = "角色值")
    private Roles value;
    /**
     * 角色描述
     */
    @Alias("角色描述")
    @Schema(description = "角色描述")
    private String remarks;
    /**
     * 数据来源
     */
    @TableField("data_source")
    @Schema(description = "数据来源")
    private SourceEnum dataSource;

    /**
     * 创建人
     */
    @TableField(value = "creator", fill = FieldFill.INSERT)
    @Schema(description = "创建人")
    private String creator;


    /**
     * 权限
     */
    @TableField(exist = false)
    @Schema(description = "权限")
    private List<RoleMenuVO> roleMenuVOS;


    /**
     * 关联人员
     */
    @TableField(exist = false)
    @Schema(description = "关联人员")
    private List<RoleUserVO> userRoleVOS;


    @Override
    public Serializable pkVal() {
        return this.id;
    }

}
